namespace SilverSea.Untilities
{
    using Microsoft.CSharp.RuntimeBinder;
    using Microsoft.Office.Interop.Excel;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Drawing;
    using System.Globalization;
    using System.Runtime.CompilerServices;
    using System.Threading;
    using System.Windows.Forms;

    public static class ExportDGV
    {
        private static ArrayList arrayList_0 = new ArrayList();
        public static string CompanyAddress = string.Empty;
        public static string CompanyName = string.Empty;
        public static bool DisplayPrintOption = false;
        public static bool FastExport = true;
        public static bool FitToPageWidth = true;
        public static int HeaderHeight = 40;
        private static int int_0 = 100;
        public static bool IsLanscape = true;
        private static List<string> list_0 = new List<string>();
        private static List<string> list_1 = new List<string>();
        public static List<string> Notices = new List<string>();
        public static bool PrintDateTime = false;
        public static bool PrintNotice = false;
        public static string PrintTitle = string.Empty;
        public static string PrintTitleDetail1 = string.Empty;
        public static string PrintTitleDetail2 = string.Empty;
        private static string string_0 = "Ng\x00e0y .... th\x00e1ng .... năm ....";
        private static string string_1 = "Người kiểm tra";
        private static string string_2 = "Người duyệt";

        public static void Export(DataGridView dataGridView)
        {
            CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            try
            {
                Microsoft.Office.Interop.Excel.Application application = (Microsoft.Office.Interop.Excel.Application) Activator.CreateInstance(System.Type.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));
                Workbook workbook = application.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
                if (Class0.callSite_0 == null)
                {
                    Class0.callSite_0 = CallSite<Func<CallSite, object, Worksheet>>.Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Worksheet), typeof(ExportDGV)));
                }
                Worksheet worksheet = Class0.callSite_0.Target(Class0.callSite_0, workbook.Worksheets[1]);
                if (Class0.callSite_1 == null)
                {
                    Class0.callSite_1 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                }
                Microsoft.Office.Interop.Excel.Range range = Class0.callSite_1.Target(Class0.callSite_1, worksheet.Cells[1, 1]);
                worksheet.PageSetup.TopMargin = 25.0;
                worksheet.PageSetup.LeftMargin = 10.0;
                worksheet.PageSetup.RightMargin = 10.0;
                worksheet.PageSetup.BottomMargin = 30.0;
                worksheet.PageSetup.PaperSize = XlPaperSize.xlPaperA4;
                worksheet.PageSetup.CenterHorizontally = true;
                worksheet.PageSetup.CenterFooter = "Page &P of &N";
                worksheet.PageSetup.Zoom = int_0;
                if (IsLanscape)
                {
                    worksheet.PageSetup.Orientation = XlPageOrientation.xlLandscape;
                }
                else
                {
                    worksheet.PageSetup.Orientation = XlPageOrientation.xlPortrait;
                }
                list_1.Clear();
                foreach (DataGridViewColumn column in dataGridView.Columns)
                {
                    if (column.Visible)
                    {
                        list_1.Add(column.HeaderText.Replace('\n', ' '));
                    }
                }
                if (DisplayPrintOption)
                {
                    PrintOptions options = new PrintOptions(list_1);
                    if (options.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    list_0 = options.GetSelectedColumns();
                    FitToPageWidth = options.FitToPageWidth;
                }
                else
                {
                    list_0 = list_1;
                }
                Splash.Show();
                int num = 1;
                int width = 0;
                int num3 = 0;
                foreach (DataGridViewColumn column2 in dataGridView.Columns)
                {
                    if (column2.Visible && list_0.Contains(column2.HeaderText.Replace('\n', ' ')))
                    {
                        num3 += column2.Width;
                    }
                }
                arrayList_0.Clear();
                foreach (DataGridViewColumn column3 in dataGridView.Columns)
                {
                    if (column3.Visible && list_0.Contains(column3.HeaderText.Replace('\n', ' ')))
                    {
                        if (FitToPageWidth)
                        {
                            width = (int) Math.Floor((double) (((((double) column3.Width) / ((double) num3)) * num3) * (((worksheet.StandardWidth * 96.0) * 2.54) / ((double) num3))));
                        }
                        else
                        {
                            width = column3.Width;
                        }
                        arrayList_0.Add(width);
                    }
                }
                foreach (DataGridViewColumn column4 in dataGridView.Columns)
                {
                    if (column4.Visible && list_0.Contains(column4.HeaderText.Replace('\n', ' ')))
                    {
                        if (Class0.callSite_2 == null)
                        {
                            Class0.callSite_2 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                        }
                        range = Class0.callSite_2.Target(Class0.callSite_2, worksheet.Cells[7, num]);
                        range.RowHeight = HeaderHeight;
                        range.VerticalAlignment = XlVAlign.xlVAlignCenter;
                        range.Font.Name = dataGridView.ColumnHeadersDefaultCellStyle.Font.Name;
                        range.Font.Bold = true;
                        range.Font.Size = 8;
                        if (FitToPageWidth)
                        {
                            range.ColumnWidth = ((double) ((int) arrayList_0[num - 1])) / (dataGridView.Font.SizeInPoints * 2.54);
                        }
                        if (!FastExport)
                        {
                            range.Interior.ColorIndex = 15;
                            range.Borders.Weight = XlBorderWeight.xlThin;
                            range.Borders.LineStyle = XlLineStyle.xlContinuous;
                            range.Borders.ColorIndex = XlColorIndex.xlColorIndexAutomatic;
                        }
                        range.Value2 = "'" + column4.HeaderText;
                        num++;
                    }
                }
                for (int i = 1; i <= 6; i++)
                {
                    if (Class0.callSite_3 == null)
                    {
                        Class0.callSite_3 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                    }
                    if (Class0.callSite_4 == null)
                    {
                        Class0.callSite_4 = CallSite<Func<CallSite, object, object, object, object>>.Create(Binder.GetIndex(CSharpBinderFlags.None, typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                    }
                    if (Class0.callSite_5 == null)
                    {
                        Class0.callSite_5 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                    }
                    range = Class0.callSite_3.Target(Class0.callSite_3, Class0.callSite_4.Target(Class0.callSite_4, Class0.callSite_5.Target(Class0.callSite_5, worksheet), worksheet.Cells[i, 1], worksheet.Cells[i, num - 1]));
                    range.Merge(true);
                    range.Font.Name = dataGridView.Font.Name;
                    if ((i == 1) && (CompanyName != string.Empty))
                    {
                        range.Font.Bold = false;
                        range.Font.Size = 10;
                        range.HorizontalAlignment = XlHAlign.xlHAlignLeft;
                        range.Value2 = CompanyName;
                    }
                    if ((i == 2) && (CompanyAddress != string.Empty))
                    {
                        range.Font.Bold = false;
                        range.Font.Size = 10;
                        range.HorizontalAlignment = XlHAlign.xlHAlignLeft;
                        range.Value2 = CompanyAddress;
                    }
                    if (i == 3)
                    {
                        range.Font.Bold = true;
                        range.Font.Size = 14;
                        range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                        range.Value2 = PrintTitle;
                    }
                    if (i == 4)
                    {
                        range.Font.Bold = false;
                        range.Font.Size = 10;
                        range.HorizontalAlignment = XlHAlign.xlHAlignLeft;
                        range.Value2 = PrintTitleDetail1;
                    }
                    if (i == 5)
                    {
                        range.Font.Bold = false;
                        range.Font.Size = 10;
                        range.HorizontalAlignment = XlHAlign.xlHAlignLeft;
                        range.Value2 = PrintTitleDetail2;
                    }
                }
                string[,] strArray = new string[dataGridView.RowCount, num - 1];
                foreach (DataGridViewRow row in (IEnumerable) dataGridView.Rows)
                {
                    num = 1;
                    foreach (DataGridViewColumn column5 in dataGridView.Columns)
                    {
                        if (column5.Visible && list_0.Contains(column5.HeaderText.Replace('\n', ' ')))
                        {
                            if (!FastExport)
                            {
                                if (Class0.callSite_6 == null)
                                {
                                    Class0.callSite_6 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                                }
                                range = Class0.callSite_6.Target(Class0.callSite_6, worksheet.Cells[row.Index + 8, num]);
                                range.Font.Name = dataGridView.DefaultCellStyle.Font.Name;
                                range.Font.Size = 8;
                                if ((row.DefaultCellStyle.BackColor == Color.LightGray) || (column5.DefaultCellStyle.BackColor == Color.LightGray))
                                {
                                    range.Interior.ColorIndex = 15;
                                }
                                range.Borders.Weight = XlBorderWeight.xlThin;
                                range.Borders.LineStyle = XlLineStyle.xlContinuous;
                                range.Borders.ColorIndex = XlColorIndex.xlColorIndexAutomatic;
                                range.Value2 = "'" + row.Cells[column5.Index].Value.ToString();
                            }
                            else
                            {
                                strArray[row.Index, num - 1] = row.Cells[column5.Index].Value.ToString();
                            }
                            num++;
                        }
                    }
                }
                if (FastExport)
                {
                    if (Class0.callSite_7 == null)
                    {
                        Class0.callSite_7 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                    }
                    if (Class0.callSite_8 == null)
                    {
                        Class0.callSite_8 = CallSite<Func<CallSite, object, object, object, object>>.Create(Binder.GetIndex(CSharpBinderFlags.None, typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                    }
                    if (Class0.callSite_9 == null)
                    {
                        Class0.callSite_9 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                    }
                    range = Class0.callSite_7.Target(Class0.callSite_7, Class0.callSite_8.Target(Class0.callSite_8, Class0.callSite_9.Target(Class0.callSite_9, worksheet), worksheet.Cells[8, 1], worksheet.Cells[(dataGridView.RowCount - 1) + 8, num - 1]));
                    range.Font.Name = dataGridView.DefaultCellStyle.Font.Name;
                    range.Font.Size = 8;
                    range.Value2 = strArray;
                }
                if (PrintDateTime)
                {
                    if (Class0.callSite_10 == null)
                    {
                        Class0.callSite_10 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                    }
                    if (Class0.callSite_11 == null)
                    {
                        Class0.callSite_11 = CallSite<Func<CallSite, object, object, object, object>>.Create(Binder.GetIndex(CSharpBinderFlags.None, typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                    }
                    if (Class0.callSite_12 == null)
                    {
                        Class0.callSite_12 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                    }
                    range = Class0.callSite_10.Target(Class0.callSite_10, Class0.callSite_11.Target(Class0.callSite_11, Class0.callSite_12.Target(Class0.callSite_12, worksheet), worksheet.Cells[dataGridView.RowCount + 9, 0x18], worksheet.Cells[dataGridView.RowCount + 9, 30]));
                    if (!PrintNotice)
                    {
                        if (Class0.callSite_13 == null)
                        {
                            Class0.callSite_13 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                        }
                        if (Class0.callSite_14 == null)
                        {
                            Class0.callSite_14 = CallSite<Func<CallSite, object, object, object, object>>.Create(Binder.GetIndex(CSharpBinderFlags.None, typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                        }
                        if (Class0.callSite_15 == null)
                        {
                            Class0.callSite_15 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                        }
                        range = Class0.callSite_13.Target(Class0.callSite_13, Class0.callSite_14.Target(Class0.callSite_14, Class0.callSite_15.Target(Class0.callSite_15, worksheet), worksheet.Cells[dataGridView.RowCount + 9, 3], worksheet.Cells[dataGridView.RowCount + 9, 4]));
                    }
                    range.Merge(true);
                    range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                    range.Font.Name = dataGridView.Font.Name;
                    range.Font.Italic = true;
                    range.Font.Size = 8;
                    range.Value2 = string_0;
                    if (Class0.callSite_16 == null)
                    {
                        Class0.callSite_16 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                    }
                    if (Class0.callSite_17 == null)
                    {
                        Class0.callSite_17 = CallSite<Func<CallSite, object, object, object, object>>.Create(Binder.GetIndex(CSharpBinderFlags.None, typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                    }
                    if (Class0.callSite_18 == null)
                    {
                        Class0.callSite_18 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                    }
                    range = Class0.callSite_16.Target(Class0.callSite_16, Class0.callSite_17.Target(Class0.callSite_17, Class0.callSite_18.Target(Class0.callSite_18, worksheet), worksheet.Cells[dataGridView.RowCount + 10, 0x18], worksheet.Cells[dataGridView.RowCount + 10, 30]));
                    if (!PrintNotice)
                    {
                        if (Class0.callSite_19 == null)
                        {
                            Class0.callSite_19 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                        }
                        if (Class0.callSite_20 == null)
                        {
                            Class0.callSite_20 = CallSite<Func<CallSite, object, object, object, object>>.Create(Binder.GetIndex(CSharpBinderFlags.None, typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                        }
                        if (Class0.callSite_21 == null)
                        {
                            Class0.callSite_21 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                        }
                        range = Class0.callSite_19.Target(Class0.callSite_19, Class0.callSite_20.Target(Class0.callSite_20, Class0.callSite_21.Target(Class0.callSite_21, worksheet), worksheet.Cells[dataGridView.RowCount + 10, 3], worksheet.Cells[dataGridView.RowCount + 10, 4]));
                    }
                    range.Merge(true);
                    range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                    range.Font.Name = dataGridView.Font.Name;
                    range.Font.Size = 8;
                    range.Value2 = string_2;
                    if (Class0.callSite_22 == null)
                    {
                        Class0.callSite_22 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                    }
                    if (Class0.callSite_23 == null)
                    {
                        Class0.callSite_23 = CallSite<Func<CallSite, object, object, object, object>>.Create(Binder.GetIndex(CSharpBinderFlags.None, typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                    }
                    if (Class0.callSite_24 == null)
                    {
                        Class0.callSite_24 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                    }
                    range = Class0.callSite_22.Target(Class0.callSite_22, Class0.callSite_23.Target(Class0.callSite_23, Class0.callSite_24.Target(Class0.callSite_24, worksheet), worksheet.Cells[dataGridView.RowCount + 9, 0x21], worksheet.Cells[dataGridView.RowCount + 9, 0x25]));
                    if (!PrintNotice)
                    {
                        if (Class0.callSite_25 == null)
                        {
                            Class0.callSite_25 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                        }
                        if (Class0.callSite_26 == null)
                        {
                            Class0.callSite_26 = CallSite<Func<CallSite, object, object, object, object>>.Create(Binder.GetIndex(CSharpBinderFlags.None, typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                        }
                        if (Class0.callSite_27 == null)
                        {
                            Class0.callSite_27 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                        }
                        range = Class0.callSite_25.Target(Class0.callSite_25, Class0.callSite_26.Target(Class0.callSite_26, Class0.callSite_27.Target(Class0.callSite_27, worksheet), worksheet.Cells[dataGridView.RowCount + 9, 6], worksheet.Cells[dataGridView.RowCount + 9, 8]));
                    }
                    range.Merge(true);
                    range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                    range.Font.Name = dataGridView.Font.Name;
                    range.Font.Italic = true;
                    range.Font.Size = 8;
                    range.Value2 = string_0;
                    if (Class0.callSite_28 == null)
                    {
                        Class0.callSite_28 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                    }
                    if (Class0.callSite_29 == null)
                    {
                        Class0.callSite_29 = CallSite<Func<CallSite, object, object, object, object>>.Create(Binder.GetIndex(CSharpBinderFlags.None, typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                    }
                    if (Class0.callSite_30 == null)
                    {
                        Class0.callSite_30 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                    }
                    range = Class0.callSite_28.Target(Class0.callSite_28, Class0.callSite_29.Target(Class0.callSite_29, Class0.callSite_30.Target(Class0.callSite_30, worksheet), worksheet.Cells[dataGridView.RowCount + 10, 0x21], worksheet.Cells[dataGridView.RowCount + 10, 0x25]));
                    if (!PrintNotice)
                    {
                        if (Class0.callSite_31 == null)
                        {
                            Class0.callSite_31 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                        }
                        if (Class0.callSite_32 == null)
                        {
                            Class0.callSite_32 = CallSite<Func<CallSite, object, object, object, object>>.Create(Binder.GetIndex(CSharpBinderFlags.None, typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                        }
                        if (Class0.callSite_33 == null)
                        {
                            Class0.callSite_33 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                        }
                        range = Class0.callSite_31.Target(Class0.callSite_31, Class0.callSite_32.Target(Class0.callSite_32, Class0.callSite_33.Target(Class0.callSite_33, worksheet), worksheet.Cells[dataGridView.RowCount + 10, 6], worksheet.Cells[dataGridView.RowCount + 10, 8]));
                    }
                    range.Merge(true);
                    range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                    range.Font.Name = dataGridView.Font.Name;
                    range.Font.Size = 8;
                    range.Value2 = string_1;
                }
                if (PrintNotice)
                {
                    int num5 = 0;
                    for (int j = 0; num5 < Notices.Count; j++)
                    {
                        if (Class0.callSite_34 == null)
                        {
                            Class0.callSite_34 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                        }
                        if (Class0.callSite_35 == null)
                        {
                            Class0.callSite_35 = CallSite<Func<CallSite, object, object, object, object>>.Create(Binder.GetIndex(CSharpBinderFlags.None, typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                        }
                        if (Class0.callSite_36 == null)
                        {
                            Class0.callSite_36 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                        }
                        range = Class0.callSite_34.Target(Class0.callSite_34, Class0.callSite_35.Target(Class0.callSite_35, Class0.callSite_36.Target(Class0.callSite_36, worksheet), worksheet.Cells[(dataGridView.RowCount + 9) + j, 1], worksheet.Cells[(dataGridView.RowCount + 9) + j, 10]));
                        range.Merge(true);
                        range.Font.Name = dataGridView.Font.Name;
                        range.Font.Size = 8;
                        range.Value2 = Notices[num5];
                        num5++;
                        if (Notices.Count > 3)
                        {
                            if (num5 == Notices.Count)
                            {
                                break;
                            }
                            if (Class0.callSite_37 == null)
                            {
                                Class0.callSite_37 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(ExportDGV)));
                            }
                            if (Class0.callSite_38 == null)
                            {
                                Class0.callSite_38 = CallSite<Func<CallSite, object, object, object, object>>.Create(Binder.GetIndex(CSharpBinderFlags.None, typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                            }
                            if (Class0.callSite_39 == null)
                            {
                                Class0.callSite_39 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(ExportDGV), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
                            }
                            range = Class0.callSite_37.Target(Class0.callSite_37, Class0.callSite_38.Target(Class0.callSite_38, Class0.callSite_39.Target(Class0.callSite_39, worksheet), worksheet.Cells[(dataGridView.RowCount + 9) + j, 11], worksheet.Cells[(dataGridView.RowCount + 9) + j, 0x15]));
                            range.Merge(true);
                            range.Font.Name = dataGridView.Font.Name;
                            range.Font.Size = 8;
                            range.Value2 = Notices[num5];
                            num5++;
                        }
                    }
                }
                if (!FitToPageWidth)
                {
                    worksheet.Columns.AutoFit();
                }
                worksheet.Name = PrintTitle;
                worksheet.Activate();
                Splash.Hide();
                application.Visible = true;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = currentCulture;
            }
        }

        private static void smethod_0()
        {
            try
            {
                foreach (Process process in Process.GetProcesses())
                {
                    if (process.ProcessName.ToLower().Equals("excel"))
                    {
                        process.Kill();
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("ERROR " + exception.Message);
            }
        }

        private static class Class0
        {
            public static CallSite<Func<CallSite, object, Worksheet>> callSite_0;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_1;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_10;
            public static CallSite<Func<CallSite, object, object, object, object>> callSite_11;
            public static CallSite<Func<CallSite, object, object>> callSite_12;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_13;
            public static CallSite<Func<CallSite, object, object, object, object>> callSite_14;
            public static CallSite<Func<CallSite, object, object>> callSite_15;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_16;
            public static CallSite<Func<CallSite, object, object, object, object>> callSite_17;
            public static CallSite<Func<CallSite, object, object>> callSite_18;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_19;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_2;
            public static CallSite<Func<CallSite, object, object, object, object>> callSite_20;
            public static CallSite<Func<CallSite, object, object>> callSite_21;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_22;
            public static CallSite<Func<CallSite, object, object, object, object>> callSite_23;
            public static CallSite<Func<CallSite, object, object>> callSite_24;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_25;
            public static CallSite<Func<CallSite, object, object, object, object>> callSite_26;
            public static CallSite<Func<CallSite, object, object>> callSite_27;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_28;
            public static CallSite<Func<CallSite, object, object, object, object>> callSite_29;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_3;
            public static CallSite<Func<CallSite, object, object>> callSite_30;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_31;
            public static CallSite<Func<CallSite, object, object, object, object>> callSite_32;
            public static CallSite<Func<CallSite, object, object>> callSite_33;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_34;
            public static CallSite<Func<CallSite, object, object, object, object>> callSite_35;
            public static CallSite<Func<CallSite, object, object>> callSite_36;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_37;
            public static CallSite<Func<CallSite, object, object, object, object>> callSite_38;
            public static CallSite<Func<CallSite, object, object>> callSite_39;
            public static CallSite<Func<CallSite, object, object, object, object>> callSite_4;
            public static CallSite<Func<CallSite, object, object>> callSite_5;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_6;
            public static CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>> callSite_7;
            public static CallSite<Func<CallSite, object, object, object, object>> callSite_8;
            public static CallSite<Func<CallSite, object, object>> callSite_9;
        }
    }
}

